package com.chy.controller;

import com.alibaba.fastjson.JSON;
import com.chy.common.R;
import com.chy.entity.Router;
import com.chy.service.RouterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/menu")
public class menuController {

    @Autowired
    RouterService routerService;

    /**
     * 无需登录
     * @param params
     * @return
     */
    @PostMapping("/getRouter")
    public R<Router> getRouter(@RequestBody Map<String, Object> params) {
        return routerService.getRouter(params);
    }

    @PostMapping("/getRouterList")
    public R<Router> getRouterList(@RequestBody Map<String, Object> params) {
        return routerService.getRouter(params);
    }

    @PostMapping("/addRouter")
    public R<String> addRouter(HttpServletRequest request, @RequestBody Map<String, Object> params) {
        return routerService.addRouter(request, params);
    }

    @PostMapping("/updateRouter")
    public R<String> updateRouter(HttpServletRequest request, @RequestBody Map<String, Object> params) {
        return routerService.updateRouter(request, params);
    }

    @PostMapping("/deleteRouter")
    public R<String> deleteRouter(HttpServletRequest request, @RequestBody Map<String, Object> params) {
        return routerService.deleteRouter(request, params);
    }
}
